/**
 * author:Administrator
 * date:2016/2/24
 * desc:TODO
 */
'use strict';


let list = {};
let seq = 1;

class ShopWareRepoImpl {

  static* find(id) {
    // not implement
  }

  static * genId() {
    return 'shopWare_' + (seq++);
  }

  static * store(obj) {
    if (!obj.id) obj.id = yield ShopWareRepoImpl.genId();
    list[obj.id] = obj;
  }

  static * findByShopIdWareId(shopId, wareId) {
    let ids = Object.keys(list);
    for (var id of ids) {
      let item = list[id];
      if (item.shopId == shopId && item.wareId == wareId)
        return item;
    }
    return null;
  }
}

module.exports = ShopWareRepoImpl;